﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "Element/ElementBase.h"
#include <QMainWindow>

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class QSortFilterProxyModel;
class ElementTreeModel;
class ElementGraphicsView;
class MainWindowPrivate;
class QToolButton;
class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    // 有一组互易使用的action，这是用标识
    enum ActionType{
        ActionNone=-1,
        ActionDrag,
        ActionLabel,
        ActionLine,
        ActionLinePoint,
        ActionVLine,
        ActionHLine
    };
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
signals:
    void actionTypeChanged(ActionType);
private slots:
    void on_searchEdit_textChanged(const QString &arg1);

    void on_actionElements_triggered(bool);

    void on_actionEdit_triggered(bool);

    void on_actionZoomIn_triggered();

    void on_actionZommOut_triggered();

    void on_actionNewProject_triggered();

    void on_tabWidget_currentChanged(int index);

    void on_actionOpenFile_triggered();

    void on_actionArrowLeft_triggered();

    void on_actionArrowRight_triggered();

    void on_actionHFlip_triggered();

    void on_actionVFlip_triggered();

    void on_treeView_clicked(const QModelIndex &index);

private:
    // 给工具栏分组，是他们互易选中
    void initActionsGroup();
    // 设置样式
    void initStyleSheet();
    // 优化界面细节
    void initUi();
    // 绑定信号与槽
    void initConnect();
    // 设置状态栏
    void initStatusBarUi();
private:
    Ui::MainWindow *ui;
    QToolButton *mLayoutToolBt=nullptr;
    QSortFilterProxyModel *mpFilterProxyModel;
    ElementTreeModel *mpSouceTreeModel;
    QIcon mTabIcon{"://icon/redact.svg"};
    ActionType mCurrentActionType = ActionType::ActionDrag;
    ElementBase::ElementUiBase *elementUi=nullptr;
    friend class MainWindowPrivate;
};
#endif // MAINWINDOW_H
